/*
 * usr_leds.c
 *
 *  Created on: Aug 18, 2012
 *      Author: drew
 */

#include <stdio.h>
#include <string.h>
#include "user_leds.h"

int iUserLedAction( int iLedNumber, int iOnOff )
{
	FILE * fpLed = NULL;

	char cFileString[128];

	sprintf( cFileString, "/sys/class/leds/beaglebone::usr%1d/brightness", iLedNumber );

	fpLed = fopen(cFileString, "r+");

	if( NULL == fpLed )
	{
	  return 0;
	}

	if( iOnOff )
	{
	  fwrite( "1", sizeof(char), 1, fpLed );
	}
	else
	{
	  fwrite( "0", sizeof(char), 1, fpLed );
	}

	fclose( fpLed );

	return 1;
}

